using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using BTV.TVAnyTime;

namespace BTV.Base.Printing
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1705:LongAcronymsShouldBePascalCased"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1012:AbstractTypesShouldNotHaveConstructors")]
    public abstract class BTVPrinter
    {

        private List<BTVChannel> _channels;

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
        public List<BTVChannel> Channels
        {
            get { return _channels; }
            set { _channels = value; }
        }

        public BTVPrinter(List<BTVChannel> input)
        {
            Channels = input;
        }

        private object _output;

        public object Output
        {
            get { return _output; }
            set { _output = value; }
        }

        private Stream _dataStream;

        public Stream DataStream
        {
            get { return _dataStream; }
            set { _dataStream = value; }
        }

        public virtual void ProduceReport(){}

        public virtual void WriteReportToDisk(string path) { }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2233:OperationsShouldNotOverflow", MessageId = "hour+1")]
        protected Dictionary<BTVSchedule, BTVProgram> GetFiller(BTVChannel c, int hour)
        {
            BTVProgramSchedulePairCollection firstHour = c.GetProgramsInHour(hour);
            if (firstHour.Count == 0)
            {
                return GetFiller(c, (hour + 1));
            }
            else
            {
                foreach (BTVProgramSchedulePair kvp in firstHour)
                {
                    TVAnyProgram prog = new TVAnyProgram();
                    prog.Name = "N/A";
                    prog.PID = "N/A";
                    TVAnySchedule sched = new TVAnySchedule();
                    sched.Pid = "N/A";
                    sched.StartTime = DateTime.Now;
                    sched.Duration = new TimeSpan(kvp.Schedule.StartTime.Hour, kvp.Schedule.StartTime.Minute, kvp.Schedule.StartTime.Second);
                    Dictionary<BTVSchedule, BTVProgram> ret = new Dictionary<BTVSchedule, BTVProgram>();
                    ret.Add(sched, prog);
                    return ret;
                }
            }
            //will never get here
            return null;
        }
    }
}
